<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import { preloadCoreRoutes, preloadAllRoutes } from '@/utils/routePreload'

let performanceObserver: PerformanceObserver | null = null

onMounted(() => {
  // 只预加载核心路由，避免阻塞
  preloadCoreRoutes()
  
  // 延迟预加载其他路由，避免影响初始渲染
  setTimeout(() => {
    preloadAllRoutes()
  }, 2000)
  
  // 性能监控 - 优化版本
  if ('performance' in window && 'PerformanceObserver' in window) {
    try {
      performanceObserver = new PerformanceObserver((list) => {
        for (const entry of list.getEntries()) {
          if (entry.entryType === 'navigation') {
            console.log('页面加载性能:', entry)
          }
        }
      })
      performanceObserver.observe({ entryTypes: ['navigation'] })
    } catch (error) {
      console.warn('性能监控初始化失败:', error)
    }
  }
})

onUnmounted(() => {
  // 清理性能监控
  if (performanceObserver) {
    try {
      performanceObserver.disconnect()
    } catch (error) {
      console.warn('性能监控清理失败:', error)
    }
  }
})
</script>

<style>
#app {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Inter', 'Arial', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  margin: 0;
  padding: 0;
  /* 优化渲染性能 */
  contain: layout style;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #333;
  background-color: #f5f5f5;
  /* 优化滚动性能 */
  -webkit-overflow-scrolling: touch;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 数据层颜色 */
.layer-tds {
  color: #FF9F43;
}

.layer-ods {
  color: #FF6B6B;
}

.layer-dwd {
  color: #4ECDC4;
}

.layer-dws {
  color: #45B7D1;
}

.layer-dim {
  color: #A55EEA;
}

.layer-ads {
  color: #96CEB4;
}

/* 状态颜色 */
.status-running {
  color: #67C23A;
}

.status-finished {
  color: #409EFF;
}

.status-failed {
  color: #F56C6C;
}

.status-canceled {
  color: #909399;
}

/* 性能优化样式 */
.performance-optimized {
  /* 启用硬件加速 */
  transform: translateZ(0);
  /* 防止重排 */
  contain: layout style;
  /* 优化动画 */
  will-change: auto;
}

/* 减少重绘的动画 */
.smooth-transition {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* 使用 transform 而不是改变布局属性 */
  transform: translateZ(0);
}
</style> 